const express = require("express");
const router = express.Router();
const cates_handle = require("../router_handler/artcate");

// 验证数据的中间件
const expressJoi = require("@escook/express-joi");

// 导入需要的验证规则
const {
  add_cates_schema,
  delect_art_cates,
  get_art_cates,
  update_art_cates,
} = require("../schema/artcate");

// 获取文章分类接口
router.get("/cates", cates_handle.getArtCates);

// 新增文章分类接口
router.post(
  "/addCates",
  expressJoi(add_cates_schema),
  cates_handle.addArtCates
);

// 删除文章分类的接口
router.get(
  "/deleteCates/:id",
  expressJoi(delect_art_cates),
  cates_handle.delectArtCates
);

// 获取文章分类 单个
router.get(
  "/getCateById/:id",
  expressJoi(get_art_cates),
  cates_handle.getCateById
);

// 根据id更新文章分类
router.post(
  "/updateCateById",
  expressJoi(update_art_cates),
  cates_handle.updateCateById
);
module.exports = router;
